#include"threadPool.h"


//线程池初始化
int threadPoolInit(threadPool_t* pool, int threadNum, int taskQueueLen){
    //初始化线程池
    pool->worker.workerNum = threadNum;
    pool->worker.tid = (pthread_t*)calloc(threadNum,sizeof(pthread_t));
    if(pool->worker.tid == NULL){
        perror("calloc");
        return -1;  
    }
    pool->taskQueue.head = NULL;
    pool->taskQueue.tail = NULL;
    pool->taskQueue.taskNum = 0;
    pool->shutdownFlag = 0;
    pool->epfd = epoll_create(1);
    if(pool->epfd == -1){
        perror("epoll_create");
        return -1;
    }
    //初始化锁和条件变量
    pthread_mutex_init(&pool->mutex,NULL);
    pthread_cond_init(&pool->cond,NULL);
    return 0;


}